#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;


int main(){
    int n;
    cin >> n;
    int index;
    int value;
    unordered_map<int,int> mymap;
    for(int i=0;i<n;i++){
        cin >> index;
        cin >> value;
        mymap[index] += value;
    }

    for(int i=0;i<=11111111;i++){
        if(mymap.count(i)) cout << i << " " << mymap.find(i)->second << endl;
    }

    return 0;
}